package other.third.entity.base;

import lombok.Getter;

import java.util.Optional;

/**
 * 天翼云CMP系统通用响应类
 *
 * @author 王霄
 * @date 2021/4/28
 */
public class ThirdResponse<T extends Verify> {

    @Getter
    private final boolean success;

    @Getter
    private final T data;

    private ThirdResponse(boolean success, T data) {
        this.success = success;
        this.data = data;
    }

    public static <T extends Verify> ThirdResponse<T> build(T data) {
        return Optional.ofNullable(data)
                .map(x -> new ThirdResponse<>(data.verify(), data))
                .orElse(null);
    }

}
